<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page language="java" import="com.tangdi.Bean.*"%>
<%@ page language="java" import="com.tangdi.Utils"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<script language="javascript" type="text/javascript"
	src="My97DatePicker/WdatePicker.js"></script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.media.js"></script>
<script type="text/javascript" src="js/jquery.mediadata.js"></script>
<title>工资条</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->	
<script type="text/javascript">
        //pdf预览
	    function showPDF(year_month, folder_Name_gzt, file_Name_gzt, dw_dm, dw_mc){
		    var x = window.screen.height;
		    var y = window.screen.width;
		    var h = 800;
		    var w = 1000;
		    var model = "title=word,resizable=yes,scrollbars=yes,height=" + h + ",width=" + w + ",status=yes,toolbar=no,menubar=no,location=no,top=" + (x-h)/2 + ",left=" + (y-w)/2;
		    var url = "";
	        pdf_url = "report_File/" + year_month + "/pdf/"+ folder_Name_gzt + "/" + year_month + "_" + file_Name_gzt + "_" + dw_dm + "_" + dw_mc + ".pdf"; 

	        //+encodeURI(pdf_url)
		    url = "showPDFdialog.jsp?pdf_url="+ pdf_url;//弹出窗口的页面内容
		    //alert(url);
		    var oOpen = window.open(url,"adviceDetail",model);
		    oOpen.focus();
	    }
		
		function check(){
			var form = document.getElementById('dwGZMXtable');
			var year_month = form.year_month.value;
			if(year_month != ""){
			   form.action="DWGZ_Pay_SlipAction?type=2";
			   }
			else{
			     alert("年月不能为空");
			     return;
			     }
			}
		
		function selectAll(){ 
			var selectAllHandler = document.getElementById("selectAllHandler"); 
			var selectAll = document.getElementsByName("file_path"); 
			for(i=0;i<selectAll.length;i++){
				selectAll[i].checked = selectAllHandler.checked; 
			} 
			  
			}
		
		 function printFile() {
			 var file_path_list=document.getElementsByName("file_path");
			 var file_paths = "";
			 for(var i = 0; i < file_path_list.length; i++){
				 if(file_path_list[i].checked){
					 file_paths = file_paths + file_path_list[i].value + ",";
					 }
				 }
			 if(file_paths == "" || file_paths.length == 0){
				 alert("请选择打印文件");
				 return;
			 }
	           $.ajax({//几个参数需要注意一下
	               type: "POST",//方法类型
	               contentType: "application/x-www-form-urlencoded; charset=utf-8",
	              // dataType: "json",//预期服务器返回的数据类型
	               url: "DWGZ_Pay_SlipAction" ,//url
	               timeout : 10000000, //超时时间设置，单位毫秒
	               data: {"type":3,"file_paths":file_paths},
	               success: function (msg) {
	                   if (msg == "success") {
	                       alert("打印完成");
	                       }else{
	                       	alert(msg);
	                       	}
	                   }
	               });
	        }

	</script>
</head>
<jsp:include page="header.jsp"></jsp:include>
<body>
	<form onSubmit="return check()" method="post" id="dwGZMXtable">
		<table>
			<tr>
				<td width="70" style="text-align:right">年月：</td>
				<td width="70"><input class="Wdate" type="text" required="true" 
					name="year_month" onfocus="WdatePicker({dateFmt:'yyyyMM'})"
					value="${year_month}" /></td>
				<td width="70"></td>
				<td width="30"><input type="submit" value="查 询" /></td>
			</tr>
		</table>
	</form>
	
	<table>
		<tr>
			<td width="5"> </td>
			<td><input type="hidden" name="year_month_file" value="${year_month}" /></td>
			<td><button type="button" onclick="printFile()">打 印</button></td>
		</tr>
	</table>
	
	<% 
    List<DW_DM_MC> dw_dm_mcList = new ArrayList<DW_DM_MC>();
    String year_month = (String)session.getAttribute("year_month");
    String folder_Name_gzt = (String)session.getAttribute("folder_Name_gzt");
    String file_Name_gzt = (String)session.getAttribute("file_Name_gzt");
    dw_dm_mcList = (List<DW_DM_MC>)session.getAttribute("dw_dm_mcList");
    
	  
	%>
	<table border="1" cellpadding="0" cellspacing="0" id="caseListTable">
		<tr class="tabletitlecolor">
			<td width="60"><input type=checkbox onclick="selectAll()"
				id="selectAllHandler">全选<br></td>
			<td width="150" align="center">单位代码</td>
			<td width="450" align="center">单位名称</td>
			<td width="150" align="center">操 作</td>
		</tr>
		<% 
		String tr_style = "";
    if(dw_dm_mcList != null && folder_Name_gzt != null){
	    for(int j = 0; j < dw_dm_mcList.size(); j++){	
	    	DW_DM_MC dm_mc = dw_dm_mcList.get(j);
	        //列值 --start
	    	if(j % 2 == 0){
				tr_style = "evenrowcolor";
			}else{
				tr_style = "oddrowcolor";
			}
	%>
		<tr class="<%=tr_style%>">
			<td><input type=checkbox name="file_path" id=<%=dm_mc.getDM()%> value="<%=year_month%>/pdf/<%=folder_Name_gzt %>/<%=year_month%>_<%=file_Name_gzt %>_<%=dm_mc.getDM()%>_<%=dm_mc.getMC()%>.pdf" /></td>
			<td><div align="center"><%= dm_mc.getDM()%></div></td>
			<td><div align="left"><%= dm_mc.getMC()%></div></td>
			<td align="center">
				<INPUT type="button" name="inputboxbt" value="PDF预览" onclick="showPDF('<%=year_month%>', '<%=folder_Name_gzt %>', '<%=folder_Name_gzt %>', '<%=dm_mc.getDM()%>', '<%=dm_mc.getMC()%>')">
                
                <a href="${pageContext.request.contextPath}/report_File/<%=year_month%>/excel/<%=folder_Name_gzt %>/<%=year_month%>_<%=folder_Name_gzt %>_<%=dm_mc.getDM()%>_<%=dm_mc.getMC()%>.xls">导出Excel</a>
			</td>
		</tr>
		<% 
		}
    }else{%>
		<p>未查到信息</p>
		<% }
   	%>
	</table>
</body>
</html>
